package com.spic.system.api.factory;

import com.spic.common.core.domain.R;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.system.api.RemoteNoticeInfoService;
import com.spic.system.api.domain.SysNoticeInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author yangjie
 * @create 2021-11-05 16:10
 */
@Component
public class RemoteNoticeInfoFallbackFactory implements FallbackFactory<RemoteNoticeInfoService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteNoticeInfoFallbackFactory.class);
    @Override
    public RemoteNoticeInfoService create(Throwable throwable)
    {
        log.error("获取系统消息服务失败:{}", throwable.getMessage());
        return new RemoteNoticeInfoService()
        {
            @Override
            public R<AjaxResult> add(SysNoticeInfo sysNoticeInfo)
            {
                return R.fail("新增系统消息失败:" + throwable.getMessage());
            }
        };
    }
}
